package com.atguigu.tingshu.user.wx;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;


/**
 * Author  王东剑
 * Created on 6/6/2024 PM4:39
 * Package_name com.atguigu.tingshu.user.wx
 * Description
 */
@Configuration
@Slf4j
public class WxMaConfiguration {
	@Autowired
	private WxMaProperties wxMaProperties;
	@Bean
	public WxMaConfig config() {
		WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
		config.setAppid(wxMaProperties.getAppId());
		config.setSecret(wxMaProperties.getAppSecret());
		config.setMsgDataFormat("JSON");
		return config;
	}
	@Bean
	public WxMaService wxMaService(WxMaConfig config) {
		WxMaService service = new WxMaServiceImpl();
		service.setWxMaConfig(config);
		return service;
	}

}
